package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.RightdetailType;
import com.ktgj.customer.service.IRightdetailTypeService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 权益类型Controller
 * 
 * @author ruoyi
 * @date 2021-07-30
 */
@RestController
@RequestMapping("/rightdetailType")
public class RightdetailTypeController extends BaseController
{
    @Autowired
    private IRightdetailTypeService rightdetailTypeService;

    /**
     * 查询权益类型列表
     */
    @PreAuthorize(hasPermi = "customer:type:list")
    @GetMapping("/list")
    public TableDataInfo list(RightdetailType rightdetailType)
    {
        startPage();
        List<RightdetailType> list = rightdetailTypeService.selectRightdetailTypeList(rightdetailType);
        return getDataTable(list);
    }

    /**
     * 导出权益类型列表
     */
    @PreAuthorize(hasPermi = "customer:type:export")
    @Log(title = "权益类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RightdetailType rightdetailType) throws IOException
    {
        List<RightdetailType> list = rightdetailTypeService.selectRightdetailTypeList(rightdetailType);
        ExcelUtil<RightdetailType> util = new ExcelUtil<RightdetailType>(RightdetailType.class);
        util.exportExcel(response, list, "权益类型数据");
    }

    /**
     * 获取权益类型详细信息
     */
    @PreAuthorize(hasPermi = "customer:type:query")
    @GetMapping(value = "/{rightdetailTypeId}")
    public AjaxResult getInfo(@PathVariable("rightdetailTypeId") Long rightdetailTypeId)
    {
        return AjaxResult.success(rightdetailTypeService.selectRightdetailTypeById(rightdetailTypeId));
    }

    /**
     * 新增权益类型
     */
    @PreAuthorize(hasPermi = "customer:type:add")
    @Log(title = "权益类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RightdetailType rightdetailType)
    {
        return toAjax(rightdetailTypeService.insertRightdetailType(rightdetailType));
    }

    /**
     * 修改权益类型
     */
    @PreAuthorize(hasPermi = "customer:type:edit")
    @Log(title = "权益类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RightdetailType rightdetailType)
    {
        return toAjax(rightdetailTypeService.updateRightdetailType(rightdetailType));
    }

    /**
     * 删除权益类型
     */
    @PreAuthorize(hasPermi = "customer:type:remove")
    @Log(title = "权益类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rightdetailTypeIds}")
    public AjaxResult remove(@PathVariable Long[] rightdetailTypeIds)
    {
        return toAjax(rightdetailTypeService.deleteRightdetailTypeByIds(rightdetailTypeIds));
    }
}
